package servlet;

import java.io.IOException;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import news.*;

public class ModifyNewsServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int nid = Integer.parseInt(request.getParameter("nid"));
		int ntid = Integer.parseInt(request.getParameter("ntid"));
		News n = NewsDao.dao.findOneNews(nid);
		List<Topic> tlist = TopicDao.dao.showAllTopic();
		List<Comments> clist = CommentsDao.dao.findComments(nid);
		request.setAttribute("nid", nid);
		request.setAttribute("news", n);
		request.setAttribute("ntid", ntid);
		request.setAttribute("tlist", tlist);
		request.setAttribute("clist", clist);
		request.setAttribute("clistSize", clist.size());

		request.getRequestDispatcher("WEB-INF/jsp/modifynews.jsp").forward(
				request, response);

	}

}
